<Window x:Class="ScrumSprintMonitor.TestbenchApp.Views.TestbenchView.TestbenchWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:ScrumSprintMonitor.TestbenchApp"
    xmlns:WPFToolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
    Title="Scrum Sprint Monitor Testbench"
    Width="700" Background="Gray"
    WindowStartupLocation="CenterScreen"
    Opacity="0.75" Activated="OnWindowActivated" MouseLeftButtonDown="OnWindowMouseLeftButtonDown">

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/ScrumSprintMonitor.UI.Wpf;component/Styles/FormResourceDictionary.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <local:XamlServiceLocator x:Key="serviceLocator" />
        </ResourceDictionary>
    </Window.Resources>

    <Window.Style>
        <StaticResource ResourceKey="DefaultChrome"/>
    </Window.Style>

    <Grid DataContext="{Binding Path=TestbenchViewModel, Source={StaticResource serviceLocator}}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Label Style="{StaticResource LabelStyle}" Grid.Row="0" Grid.Column="0" Content="Current _Build Status:" Target="{Binding ElementName=CurrentBuildStatus}" />
        <ComboBox x:Name="CurrentBuildStatus" Style="{StaticResource ComboBoxStyle}" Grid.Row="0" Grid.Column="1" ItemsSource="{Binding AvailableBuildStatus}" SelectedValue="{Binding CurrentBuildStatus}" VerticalAlignment="Center"/>

        <ContentControl Grid.Row="1" Grid.ColumnSpan="2" ContentTemplate="{StaticResource Separator}" Content="Work Items" IsTabStop="False"/>
        <WPFToolkit:DataGrid Margin="0,3" Grid.Row="2" Grid.ColumnSpan="2" ItemsSource="{Binding WorkItems}" ItemStringFormat="" GridLinesVisibility="All" Foreground="Black" CanUserAddRows="True" CanUserDeleteRows="True" BorderThickness="1" AlternationCount="1" AlternatingRowBackground="WhiteSmoke" VerticalGridLinesBrush="Gainsboro" HorizontalGridLinesBrush="Cornsilk" HorizontalContentAlignment="Left" HorizontalAlignment="Stretch" AreRowDetailsFrozen="True" AutoGenerateColumns="False" VerticalContentAlignment="Center">
            <WPFToolkit:DataGrid.Columns>
                <WPFToolkit:DataGridTextColumn Header="#" Binding="{Binding Path=Id}" Width="Auto" IsReadOnly="True" />
                <WPFToolkit:DataGridTextColumn Header="Type" Binding="{Binding Path=Type}" Width="Auto" IsReadOnly="True" />
                <WPFToolkit:DataGridTemplateColumn Header="State" Width="80">
                    <WPFToolkit:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding State}" VerticalAlignment="Center" Margin="3" />
                        </DataTemplate>
                    </WPFToolkit:DataGridTemplateColumn.CellTemplate>
                    <WPFToolkit:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox ItemsSource="{Binding Path=TestbenchViewModel.ValidWorkItemStates, Source={StaticResource serviceLocator}}" SelectedItem="{Binding State}" IsDropDownOpen="True" />
                        </DataTemplate>
                    </WPFToolkit:DataGridTemplateColumn.CellEditingTemplate>
                </WPFToolkit:DataGridTemplateColumn>
                <WPFToolkit:DataGridTextColumn Header="Title" Binding="{Binding Title}" Width="*" />
                <WPFToolkit:DataGridTextColumn Header="Done Work" Width="Auto" Binding="{Binding DoneWork}"/>
                <WPFToolkit:DataGridTextColumn Header="Remaining Work" Width="Auto" Binding="{Binding RemainingWork}"/>
                <WPFToolkit:DataGridTemplateColumn Header="Assigned To" Width="Auto">
                    <WPFToolkit:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding AssignedTo}" VerticalAlignment="Center" Margin="3" />
                        </DataTemplate>
                    </WPFToolkit:DataGridTemplateColumn.CellTemplate>
                    <WPFToolkit:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox ItemsSource="{Binding Path=TestbenchViewModel.ValidTeamMembers, Source={StaticResource serviceLocator}}" SelectedItem="{Binding AssignedTo}" IsDropDownOpen="True" />
                        </DataTemplate>
                    </WPFToolkit:DataGridTemplateColumn.CellEditingTemplate>
                </WPFToolkit:DataGridTemplateColumn>
            </WPFToolkit:DataGrid.Columns>
        </WPFToolkit:DataGrid>

        <Label Style="{StaticResource LabelStyle}" Grid.Row="3" Grid.Column="0" Content="Team Member making c_hanges:" Target="{Binding ElementName=TeamMemberMakingChanges}" />
        <ComboBox x:Name="TeamMemberMakingChanges" Style="{StaticResource ComboBoxStyle}" Grid.Row="3" Grid.Column="1" ItemsSource="{Binding ValidTeamMembers}" SelectedItem="{Binding CurrentCommiter}" />

        <Button Grid.Row="4" Grid.ColumnSpan="2" Content="_Close" Command="{Binding CloseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" HorizontalAlignment="Right" Padding="12,6" Margin="0,3" IsDefault="True" />
    </Grid>
</Window>
